package tcu.iot.gasmanage.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import tcu.iot.gasmanage.entity.Value;
import tcu.iot.gasmanage.entity.equipment.Equipment;
import tcu.iot.gasmanage.entity.Options;

import java.util.List;

@Repository
@Mapper
@Component("DataTable")
public interface DataTableMapper {

    //根据equipmentNumber，所有数据库中这个设备的信息
    @Select("SELECT * FROM equipment WHERE equipmentNumber=#{equipmentNumber}")
    Equipment FindAEquipment(String equipmentNumber);

    //搜索数据库中所有设备equipmentNumber选项
    @Select("SELECT equipmentNumber,equipmentName FROM equipment")
    @Results({@Result(property = "key",column = "equipmentNumber"),@Result(property = "label",column = "equipmentName")})
    List<Options> FindEquipmentNumber();

    @Select("SELECT equipmentNumber,equipmentName FROM equipment")
    @Results({@Result(property = "value",column = "equipmentNumber"),@Result(property = "label",column = "equipmentName")})
    List<Value> FindEquipmentNumberName();
}
